package com.ddone.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ddone.bean.User;
import com.ddone.bean.vo.ResultVo;
import com.ddone.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ddone
 * @date 2024/3/25-22:36
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping
    public List<User> list() {
        return userService.list();
    }

    @GetMapping("/page/{pageNo}/{pageSize}")
    public List<User> page(@PathVariable("pageNo") Long pageNo, @PathVariable("pageSize") Long pageSize) {

        return userService.page(new Page<User>(pageNo, pageSize)).getRecords();
    }

    @GetMapping("/vo")
    public ResultVo listVo() {
        return new ResultVo(userService.page(new Page<User>(10, 3)).getRecords());
    }
}
